package cn.jsj.dao;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

/**
 * 获取HB中的session对象的工具类
 * @author li
 *
 */
public class HBUtils {

	//session的工厂类
	private static SessionFactory sessionFactory;

	//获取session
	public static Session getSession(){
		return sessionFactory.openSession();
	}
	//静态块
	static{
		try{
			sessionFactory=new Configuration().configure().buildSessionFactory();
		}catch(Exception e)
		{
			throw new ExceptionInInitializerError(e);
		}
	}

}
